package top.ninwoo.cloud.ipservice.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.ninwoo.cloud.ipservice.service.IpService;

import javax.annotation.Resource;
import java.util.Set;

@RestController
public class IpController {

    @Resource
    private IpService ipService;

    @RequestMapping("/assignIp")
    public String assignIp(long clusterId, String appName, String cid, String ipRange) {
        return ipService.assignIp(clusterId, appName, cid, ipRange);
    }

    @RequestMapping("/getIpByContainerId")
    public String getIpByContainerId(String cid) {
        return ipService.getContainerIp(cid);
    }

    @RequestMapping("/getIpListByAppName")
    public Set<String> getIpListByAppName(long clusterId, String appName) {
        return ipService.getIpListByAppName(clusterId, appName);
    }

    @RequestMapping("/clearIpByClusterId")
    public String clearIpByClusterId(long clusterId) {
        return ipService.clearIpByClusterId(clusterId);
    }

    @RequestMapping("/deleteIp")
    public String deleteIp(long clusterId, String appName, String containerId, String ip) {
        ipService.deleteIp(clusterId, appName, containerId, ip);
        return "success";
    }


}